package org.example.com.atguigu.day05;

import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.SparkSession;
import org.junit.Test;

public class Reader {
    @Test
    public void readTextFile(){
        SparkSession spark = SparkSession.builder().master("local[4]").appName("test").getOrCreate();
        spark.read().text("E:\\IdeaProject\\bigdata0228\\spark0228\\datas\\user.txt").show();
    }

    @Test
    public void readJsonFile(){
        SparkSession spark = SparkSession.builder().master("local[4]").appName("test").getOrCreate();
        spark.read().json("E:\\IdeaProject\\bigdata0228\\spark0228\\datas\\js.txt").show();
    }

    @Test
    public void readCsvFile(){
        SparkSession spark = SparkSession.builder().master("local[4]").appName("test").getOrCreate();
        Dataset<Row> csv = spark.read().option("sep", "_").csv("E:\\IdeaProject\\bigdata0228\\spark0228\\datas\\stu.txt");
        csv.toDF("id","name","age").show();
    }

    @Test
    public void readParquetFile(){
        SparkSession spark = SparkSession.builder().master("local[4]").appName("test").getOrCreate(); 
    }
}
